﻿#define CL_TARGET_OPENCL_VERSION 300
//#include <CL/opencl.h>
#include "pch.h"
#include <CL/cl.h>
#include <stdio.h>
#include <stdlib.h>


int main1()
{
	cl_int CL_err = CL_SUCCESS;
	cl_uint numPlatforms = 0;

	CL_err = clGetPlatformIDs(0, NULL, &numPlatforms);
	if (CL_err == CL_SUCCESS)
		printf_s("%u platform(s) found\n", numPlatforms);
	else
		printf_s("clGetPlatformIDs(%i)\n", CL_err);

	cl_platform_id* pids;
	pids = (cl_platform_id*)malloc(sizeof(cl_platform_id) * numPlatforms);
	CL_err = clGetPlatformIDs(numPlatforms, pids, &numPlatforms);
	if (CL_err == CL_SUCCESS)
	{
		char value[1024];
		size_t ret;
		for (cl_uint i = 0; i < numPlatforms; i++)
		{
			printf_s("%u %d ", i, pids[i]);
			//平台名称
			clGetPlatformInfo(pids[i], CL_PLATFORM_NAME, 1024, value, &ret);
			if(ret>0)
				printf_s("%s ", value);
			//平台概述
			clGetPlatformInfo(pids[i], CL_PLATFORM_PROFILE, 1024, value, &ret);
			if (ret > 0)
				printf_s("%s ", value);
			//平台版本
			clGetPlatformInfo(pids[i], CL_PLATFORM_VERSION, 1024, value, &ret);
			if (ret > 0)
				printf_s("%s ", value);
			//平台版本
			clGetPlatformInfo(pids[i], CL_PLATFORM_VENDOR, 1024, value, &ret);
			if (ret > 0)
				printf_s("%s ", value);
			clGetPlatformInfo(pids[i], CL_PLATFORM_EXTENSIONS, 1024, value, &ret);
			if (ret > 0)
				printf_s("%s ", value);
			//clGetPlatformInfo(pids[i], CL_PLATFORM_NUMERIC_VERSION, 1024, value, &ret);
			//if (ret > 0)
			//	printf_s("%s ", value);
			//clGetPlatformInfo(pids[i], CL_PLATFORM_EXTENSIONS_WITH_VERSION, 1024, value, &ret);
			//if (ret > 0)
			//	printf_s("%s ", value);
			printf_s("\n");
		}
	}
	else
		printf_s("clGetPlatformIDs(%i)\n", CL_err);
	if(pids)
		free(pids);
	return 0;
}



